Skip to content

program: Updates for better 1 SOL minimum delegation support#756

Open
joncinque wants to merge 3 commits into
solana-program:mainfrom
joncinque:min-delegation
Open

program: Updates for better 1 SOL minimum delegation support#756
joncinque wants to merge 3 commits into
solana-program:mainfrom
joncinque:min-delegation

Conversation

@joncinque

Copy link
Copy Markdown
Contributor

Problem

The version of solana-program-test used by the repo doesn't properly add the BPF version of the stake program in tests -- if you take the current main branch, use the BPF stake program currently on mainnet, and run the tests, you'll see the minimum delegation reported is just 1 lamport.

On top of that, with the 1 SOL minimum delegation, the minimum limits used during withdraw_stake to figure out if one of the edge cases apply is too strict. It currently requires that the stake account withdrawn from has at least rent_exemption + minimum_delegation + 1, assuming that we can split 1 lamport from a stake account.

Since we need to split at least 1 SOL, we can have a situation where a stake account has rent_exemption + 1_999_999_999 lamports. The stake pool program forces you to withdraw from that account, but it isn't possible.

Summary of changes

The first two commits just bump everything to the newest dependencies, update the stake program fixture, and use it correctly in program-test. Note that we have to use v4.1 because of the incompatible wincode bump in the SDK.

After that, modify withdraw_stake to use a looser bound of rent_exemption + minimum_delegation * 2 + lamports_per_pool_token as the limit where a user can withdraw from transient accounts / remove validators.

Only one existing test is tripped by the new behavior, so fix that, and add a new one.

@joncinque joncinque requested a review from 2501babe June 23, 2026 10:49
Comment thread program/src/processor.rs
Comment on lines +2962 to +2963
&& u64::from(preferred_validator_info.active_stake_lamports)
>= minimum_lamports_with_tolerance

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think >= is correct here, since if the stake account has exactly minimum_lamports_with_tolerance, it should be possible to withdraw a stake account

@joncinque

Copy link
Copy Markdown
Contributor Author

#757 will fix the audit failure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant